<?php

namespace app\common\model;

use think\Cache;
use think\Model;
use app\admin\controller\information\Inventory;

/**
 * 仓库基础资料录入数据模型
 */
class Kc extends Model
{
     public static function getList(){
         $field = 'a.id,AutoID,cInvCode,cBatch,iQuantity,cFree1,ifnull(a.shelves_id,0) shelves_id,
a.warehouse_id,a.cWhCode,b.name,IFNULL(b.specification,"") specification,
b.unit,b.unit_code,(select c.name from fa_warehouse c where c.id=a.warehouse_id) warehouse_name,
ifnull((select CONCAT_WS("||", name, number) from fa_shelves  where id=a.shelves_id),"") shelves_name_code
';
         //$data = self::field($field)->select();
         $data = db('kc')->alias('a')
                ->join('inventory b','b.number=a.cInvCode')
                //->group('AutoID')//自己新增的没有autoid
                ->field($field)
                ->where([
                    'iQuantity' => ['GT',0]
                ])
                ->select();
         return $data;
     }
}
